package com.example.smartg;

import android.app.Application;

import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;

public class HttpUtil {
    public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");

    public static void sendOkHttpRequest(final String address, final String json, final okhttp3.Callback callback) {
        OkHttpClient client = new OkHttpClient.Builder().addInterceptor(new HandlerUtils()).build();
        RequestBody requestBody = RequestBody.create(json, JSON);
        Request request = new Request.Builder()
                .url(address)
                .header("Authorization", "")
                .post(requestBody)
                .build();
        client.newCall(request).enqueue(callback);
    }
}